#! /usr/bin/env python
PACKAGE='caros_camera'

from dynamic_reconfigure.parameter_generator_catkin import *

class SensorLevels:
  RECONFIGURE_RUNNING = 0
  RECONFIGURE_STOP = 1

gen = ParameterGenerator()
#       Name                    Type      Reconfiguration level             Description                                                                                      Default    Min   Max

video_modes = gen.enum([gen.const("Format0_Mode5", str_t, "640x480_mono8", ""),
                  gen.const("Format0_Mode6", str_t, "640x480_mono16", ""),
		  gen.const("Format2_Mode1", str_t, "1280x960_bayer8", ""),
                  gen.const("Format2_Mode2", str_t, "1280x960_mono8", ""),
                  gen.const("Format2_Mode6", str_t, "1280x960_mono16", ""),
                  gen.const("Format7_Mode0", str_t, "format7_mode0", ""),
                  gen.const("Format7_Mode1", str_t, "format7_mode1", ""),
                  gen.const("Format7_Mode2", str_t, "format7_mode2", ""),
		  gen.const("Format7_Mode3", str_t, "format7_mode3", ""),
		  gen.const("Format7_Mode4", str_t, "format7_mode4", ""),
                  ],
                 "Video mode for camera.")

gen.add("video_mode", 	      str_t,    SensorLevels.RECONFIGURE_STOP,       "Video mode.",                                                                                "format7_mode0", edit_method = video_modes)

gen.add("frame_rate",         double_t, SensorLevels.RECONFIGURE_RUNNING,    "Camera speed (frames per second).",				                             7, 0, 100)

gen.add("auto_exposure",      bool_t,   SensorLevels.RECONFIGURE_RUNNING,    "Allow the camera to automatically change exposure (Combined Gain, Iris & Shutter control).",  True)
gen.add("exposure",           double_t, SensorLevels.RECONFIGURE_RUNNING,         "Auto exposure value (like contrast).",				                             1.35, -10.0, 10.0)

gen.add("auto_shutter",       bool_t,   SensorLevels.RECONFIGURE_RUNNING,     "Shutter control state.",				            		                     True)
gen.add("shutter_speed",      double_t, SensorLevels.RECONFIGURE_RUNNING,     "Amount of time (in seconds) for the apeture to remain open.",				     0.03, 0.0, 1.0)

gen.add("auto_gain",          bool_t,   SensorLevels.RECONFIGURE_RUNNING,     "Gain control state.",				                                             True)
gen.add("gain",               double_t, SensorLevels.RECONFIGURE_RUNNING,     "Relative circuit gain.",				                                             0, -10, 30)

gen.add("pan",                int_t, 	SensorLevels.RECONFIGURE_RUNNING,     "Controls camera pan.",				                                             0, -1000, 1000)

gen.add("tilt",               int_t, 	SensorLevels.RECONFIGURE_RUNNING,     "Controls camera tilt.",				                                             0, -1000, 1000)


gen.add("brightness",         double_t, SensorLevels.RECONFIGURE_RUNNING,     "Black level offset.",				                                             0.0, 0.0, 10.0)

gen.add("gamma",              double_t, SensorLevels.RECONFIGURE_RUNNING,     "Gamma expansion exponent.",				             		             1.0, 0.5, 4.0)

gen.add("auto_white_balance", bool_t,    SensorLevels.RECONFIGURE_RUNNING,     "Automatically change white balance", True)

gen.add("white_balance_blue", int_t,    SensorLevels.RECONFIGURE_RUNNING,     "White balance blue component.",				             		             800, 0, 1023)

gen.add("white_balance_red",  int_t,    SensorLevels.RECONFIGURE_RUNNING,     "White balance red component.",				             		             550, 0, 1023)

# Format7-specific parameters
gen.add("format7_roi_width", int_t, SensorLevels.RECONFIGURE_STOP,         "Width of Format7 Region of Interest in unbinned pixels, full width if zero.",                 0, 0, 65535)

gen.add("format7_roi_height", int_t, SensorLevels.RECONFIGURE_STOP,        "Height of Format7 Region of Interest in unbinned pixels, full height if zero.",               0, 0, 65535)

gen.add("format7_x_offset", int_t, SensorLevels.RECONFIGURE_STOP,          "Horizontal offset for left side of Format7 ROI in unbinned pixels.",                          0, 0, 65535)

gen.add("format7_y_offset", int_t, SensorLevels.RECONFIGURE_STOP,          "Vertical offset for top of Format7 ROI in unbinned pixels.",                                  0, 0, 65535)

codings = gen.enum([gen.const("Mono8", str_t, "mono8", ""),
                    gen.const("Mono16", str_t, "mono16", ""),
                    gen.const("Raw8", str_t, "raw8", ""),
                    gen.const("Raw16", str_t, "raw16", "")],
                    "Format7 color coding methods")

gen.add("format7_color_coding", str_t, SensorLevels.RECONFIGURE_STOP,      "Color coding (only for Format7 modes)",                                                       "raw8",      edit_method = codings)

# Trigger parameters
gen.add("enable_trigger",       bool_t,   SensorLevels.RECONFIGURE_RUNNING,   "Enable the external triggering mode.",                                                        False)

trigger_modes = gen.enum([gen.const("Mode0", str_t, "mode0", ""),
                    gen.const("Mode1_bulb_trigger", str_t, "mode1", ""),
                    gen.const("Mode3", str_t, "mode3", ""),
                    gen.const("Mode14", str_t, "mode14", "")],
                    "IIDC v1.31 Trigger Modes")

gen.add("trigger_mode", str_t, SensorLevels.RECONFIGURE_RUNNING,              "IIDC v1.31 Trigger Modes",                                                                    "mode0",     edit_method = trigger_modes)

gpio_pins = gen.enum([gen.const("GPIO0", str_t, "gpio0", ""),
                    gen.const("GPIO1", str_t, "gpio1", ""),
                    gen.const("GPIO2", str_t, "gpio2", ""),
                    gen.const("GPIO3", str_t, "gpio3", "")],
                    "GPIO Trigger Sources")

gen.add("trigger_source", str_t, SensorLevels.RECONFIGURE_RUNNING, "GPIO Trigger Sources",                                                                                   "gpio0",     edit_method = gpio_pins)

polarities = gen.enum([gen.const("Low", int_t, 0, "Low Polarity"),
                    gen.const("High", int_t, 1, "High Polarity")],
                    "GPIO Polarities")

gen.add("trigger_polarity", int_t, SensorLevels.RECONFIGURE_RUNNING, "GPIO Trigger Polarity", 0, edit_method = polarities)

gen.add("enable_trigger_delay",       bool_t,   SensorLevels.RECONFIGURE_RUNNING,    "Whether Trigger Delay is active.",                      				     False)

gen.add("trigger_delay",              double_t, SensorLevels.RECONFIGURE_RUNNING,    "The trigger delay to wait once triggered (in seconds).",				     0.0, 0.0, 1.0)

gen.add("trigger_parameter", 	      int_t,    SensorLevels.RECONFIGURE_RUNNING,    "Trigger mode parameter.  Varies based on mode.",                                      0, -32768, 32767)

gen.add("enable_strobe1", bool_t, SensorLevels.RECONFIGURE_RUNNING, "Whether strobe is sent.", False)

gen.add("strobe1_polarity", int_t, SensorLevels.RECONFIGURE_RUNNING, "GPIO Strobe Polarity", 0, edit_method = polarities)

gen.add("strobe1_delay", double_t, SensorLevels.RECONFIGURE_RUNNING, "The delay between capture and strobe out (in milliseconds).", 0.0, 0.0, 1000.0)

gen.add("strobe1_duration", double_t, SensorLevels.RECONFIGURE_RUNNING, "Strobe duration (in milliseconds)", 0.0, 1.0, 1000.0)

exit(gen.generate(PACKAGE, "caros_camera", "PointGrey"))
